From a3c31d5fdbb0e28d9d8da0c505493a513fafba30 Mon Sep 17 00:00:00 2001 From: robertl Date: Wed, 16 Apr 2003 17:27:44 +0000 Subject: [PATCH] From Alexm. Fix mkshort uniqueness on 'anyname' and add option to suppress uniquification. --- gpsbabel/Makefile | 4 ++-- gpsbabel/csv_util.c | 40 ++++++++++++++++++++-------------------- gpsbabel/xcsv.c | 5 +++++ 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/gpsbabel/Makefile b/gpsbabel/Makefile index 430606fdd..d50252d73 100644 --- a/gpsbabel/Makefile +++ b/gpsbabel/Makefile @@ -58,8 +58,8 @@ dep: (echo "internal_styles.c: mkstyle.sh" ; ls style/*.style) >> /tmp/dep echo Edit Makefile and bring in /tmp/dep -VERSIONU=1_1_1_beta03072003 -VERSIOND=1.1.1_beta03072003 +VERSIONU=1_1_1_beta04162003 +VERSIOND=1.1.1_beta04162003 release: rm -fr gpsbabel-$(VERSIOND) cvs tag gpsbabel_$(VERSIONU) diff --git a/gpsbabel/csv_util.c b/gpsbabel/csv_util.c index 038d2585c..84c00348b 100644 --- a/gpsbabel/csv_util.c +++ b/gpsbabel/csv_util.c @@ -579,23 +579,6 @@ xcsv_waypt_pr(const waypoint *wpt) field_map_t *fmp; queue *elem, *tmp; - if (wpt->shortname) { - anyname = xstrdup(wpt->shortname); - } else - if (wpt->description) { - anyname = mkshort(xcsv_file.mkshort_handle, wpt->description); - } else - if (wpt->notes) { - anyname = xstrdup(wpt->notes); - } else - anyname = xstrdup(""); - - if ((anyname) && (global_opts.synthesize_shortnames)) { - char *oldname = anyname; - anyname = mkshort(xcsv_file.mkshort_handle, - wpt->notes ? wpt->notes : wpt->description); - xfree(oldname); - } if ((! wpt->shortname) || (global_opts.synthesize_shortnames)) { if (wpt->description) { @@ -644,7 +627,27 @@ xcsv_waypt_pr(const waypoint *wpt) sprintf(buff, fmp->printfc, shortname); } else if (strcmp(fmp->key, "ANYNAME") == 0) { + if (wpt->shortname) { + anyname = xstrdup(wpt->shortname); + } else + if (wpt->description) { + anyname = mkshort(xcsv_file.mkshort_handle, wpt->description); + } else + if (wpt->notes) { + anyname = xstrdup(wpt->notes); + } else + anyname = xstrdup(""); + + if ((anyname) && (global_opts.synthesize_shortnames)) { + char *oldname = anyname; + anyname = mkshort(xcsv_file.mkshort_handle, + wpt->notes ? wpt->notes : wpt->description); + xfree(oldname); + } + sprintf(buff, fmp->printfc, anyname); + + xfree(anyname); } else if (strcmp(fmp->key, "DESCRIPTION") == 0) { sprintf(buff, fmp->printfc, description); @@ -777,9 +780,6 @@ xcsv_waypt_pr(const waypoint *wpt) if (description) xfree(description); - if (anyname) - xfree(anyname); - index++; } diff --git a/gpsbabel/xcsv.c b/gpsbabel/xcsv.c index 690e6dfb1..004413bd5 100644 --- a/gpsbabel/xcsv.c +++ b/gpsbabel/xcsv.c @@ -34,6 +34,7 @@ static char *styleopt; static char *snlenopt; static char *snwhiteopt; static char *snupperopt; +static char *snuniqueopt; char *xcsv_urlbase; static @@ -42,6 +43,7 @@ arglist_t xcsv_args[] = { {"snlen", &snlenopt, "Max synthesized shortname length"}, {"snwhite", &snwhiteopt, "(0/1) Allow whitespace synth. shortnames"}, {"snupper", &snupperopt, "(0/1) UPPERCASE synth. shortnames"}, + {"snunique", &snuniqueopt, "(0/1) Make synth. shortnames unique"}, {"urlbase", &xcsv_urlbase, "Basename prepended to URL on output"}, {0, 0, 0} }; @@ -452,6 +454,9 @@ xcsv_wr_init(const char *fname, const char *args) if (snupperopt) setshort_mustupper(xcsv_file.mkshort_handle, atoi(snupperopt)); + if (snuniqueopt) + setshort_mustuniq(xcsv_file.mkshort_handle, atoi(snuniqueopt)); + setshort_badchars(xcsv_file.mkshort_handle, xcsv_file.badchars); } -- 2.30.2